package com.wee.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.wee.aircoach_user.R;
import com.wee.entity.Project_down;

import java.util.List;

/**
 * Created by xiaobing on 15/7/30.  动作选择适配器， 在套餐详情里面
 */
public class ActionSelectAdapter1 extends BaseAdapter{
    private Context context;
    private List<Project_down.Project_list> data;
    public int mode = 0; // 0, normal state, 1, edit state.

    public ActionSelectAdapter1(Context context, List<Project_down.Project_list> data) {
        this.context = context;
        this.data = data;

    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        try{
            ViewHolder holder1 ;
            if (convertView==null){
                holder1 = new ViewHolder();
                LayoutInflater inflate = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = inflate.inflate(R.layout.item_action_select, null);
                holder1. img=(ImageView)convertView.findViewById(R.id.image_dongzuo);
                holder1. txtName = (TextView)convertView.findViewById(R.id.text);
                holder1.txtHint = (TextView)convertView.findViewById(R.id.hint);
                convertView.setTag(holder1);
            }else{
                holder1 = (ViewHolder)convertView.getTag();
            }
            Project_down.Project_list exerciseAction = data.get(position);
            holder1.txtName.setText(""+exerciseAction.getName());
            holder1.txtHint.setText(""+exerciseAction.getCount());
            ImageLoader.getInstance().displayImage(exerciseAction.getFigure(), holder1. img);
        }catch (Exception e){

        }
        return convertView;
    }
    static class ViewHolder{
        ImageView img;
        TextView txtName,txtHint;
    }
}